package com.luoqiu.cinema.controller;

import com.luoqiu.cinema.common.PageParam;
import com.luoqiu.cinema.common.PageResult;
import com.luoqiu.cinema.common.Result;
import com.luoqiu.cinema.eitityExtends.BuyMovieParamEx;
import com.luoqiu.cinema.eitityExtends.EvaluateEx;
import com.luoqiu.cinema.entity.Movie;
import com.luoqiu.cinema.entity.MovieEvaluate;
import com.luoqiu.cinema.service.MovieService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class MovieController {

    @Resource
    private MovieService movieService;

    /**
     * 电影关联的评价
     *
     * @param pageParam
     * @return
     */
    @PostMapping(value = "/eva/list")
    public Result<PageResult<EvaluateEx>> evaList(@RequestBody PageParam pageParam) {
        return movieService.evaList(pageParam);
    }

    /**
     * 添加评论
     *
     * @return
     */
    @PostMapping(value = "eva/add")
    public Result<String> add(@RequestBody MovieEvaluate movieEvaluate) {
        return movieService.add(movieEvaluate);
    }

    /**
     * 添加电影
     * @param movie
     * @return
     */
    @PostMapping(value = "/movie/add")
    public Result<String> addM(@RequestBody Movie movie) {
        return movieService.addM(movie);
    }

    /**
     * 删除电影
     * @param id
     * @return
     */
    @GetMapping(value = "/movie/delM")
    public Result<String> delM(Integer id) {
        return movieService.delM(id);
    }

    /**
     * 替他人买
     * @param paramEx
     * @return
     */
    @PostMapping(value = "/buy/other")
    public Result<String> buyOther(@RequestBody BuyMovieParamEx paramEx) {
        return movieService.buyOther(paramEx);
    }

    /**
     * 代替他人退票
     * @param paramEx
     * @return
     */
    @PostMapping(value = "/back/other")
    public Result<String> backOther(@RequestBody BuyMovieParamEx paramEx) {
        return movieService.backOther(paramEx);
    }
}
